import React, { useEffect, useState } from 'react'

export default function App() {
  const [count, setCount] = useState(0);
  const [isHot, setIshot] = useState(true);

  /* useEffect(() => {
    console.log("没有参数"); //初始化和任何更新都执行
  }) */


  /* useEffect(() => {
    console.log("空数组"); //只有初始化执行一次
  },[]) */


  /* useEffect(() => {
    console.log("count");
    return()=>{
      console.log("卸载count" + count); //初始化和更新count执行
    }
  },[count]) */


  /* useEffect(() => {
    console.log("isHot"); //初始化和更新isHot执行
  },[isHot]) */

  useEffect(() => {
    console.log("count,isHot"); //初始化和更新count,isHot执行
  },[count,isHot])


  return (
    <div>
      <h1>count的值是{count}</h1>
      <button onClick={() => { setCount(count + 1) }}>累加</button>
      <hr />
      <h1>今天天气真{isHot ? "热" : "冷"}啊</h1>
      <button onClick={() => { setIshot(!isHot) }}>切换天气</button>
    </div>
  )
}
